package cn.quevo.core.file.draw;

import cn.quevo.core.exception.CustomException;
import cn.quevo.core.file.entity.WriteImage;
import cn.quevo.core.file.enums.ImageCodeType;
import cn.quevo.core.lang.StringUtils;

import java.awt.*;

public abstract class AbstractCodeDraw implements CodeDraw {
    @Override
    public void draw(Graphics2D gd,WriteImage writeImage) throws CustomException {
        ImageCodeType imageCodeType = writeImage.getImageCodeType();
        if (imageCodeType == null || imageCodeType == ImageCodeType.NONE || StringUtils.isBlank(writeImage.getInterLine(),1)){
            return;
        }
        imageCodeType.getValidateClass().checked(gd,writeImage);
    }

    protected abstract void checked(Graphics2D gd,WriteImage writeImage) throws CustomException;
}
